<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="font-awesome.min.css" rel="stylesheet">
    <link href="animate.min.css" rel="stylesheet">

    <link rel="stylesheet" href="leaflet.css" />
    <script src="leaflet.js"></script>

    <style>
        #map {
            width: 100%;
            height: 100%;
            position: fixed;
            top: 0px;
            left: 0px;
            right: 0px;
            bottom: 0px
        }
    </style>
</head>

<body>

    <div id='map'>
    </div>

    <script type="text/javascript">
        var getUrlParameter = function getUrlParameter(sParam) {
            var sPageURL = decodeURIComponent(window.location.search.substring(1)),
                sURLVariables = sPageURL.split('&'),
                sParameterName,
                i;

            for (i = 0; i < sURLVariables.length; i++) {
                sParameterName = sURLVariables[i].split('=');

                if (sParameterName[0] === sParam) {
                    return sParameterName[1] === undefined ? true : sParameterName[1];
                }
            }
        };

        var map = L.map('map', {
            zoomControl: true,
            attributionControl: false
        }).setView([getUrlParameter('lat'), getUrlParameter('lon')], getUrlParameter('zoom'));

        map.addLayer(new L.TileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
            minZoom: 1,
            maxZoom: 15
        }));

        if (getUrlParameter('displayPin') === 'true') {
            L.marker([getUrlParameter('lat'), getUrlParameter('lon')]).addTo(map)
        }

        // Wind
        var windLayer = new L.TileLayer("https://tile.openweathermap.org/map/wind_new/{z}/{x}/{y}.png?appid=" + getUrlParameter('appid'), {
            minZoom: 1,
            maxZoom: 15
        });
        windLayer.setOpacity(0.7);

        // Clouds
        var cloudsLayer = new L.TileLayer("https://tile.openweathermap.org/map/clouds_new/{z}/{x}/{y}.png?appid=" + getUrlParameter('appid'), {
            minZoom: 1,
            maxZoom: 15
        });
        cloudsLayer.setOpacity(0.7);
        map.addLayer(cloudsLayer);

        // Rain
        var rainLayer = new L.TileLayer("https://tile.openweathermap.org/map/precipitation_new/{z}/{x}/{y}.png?appid=" + getUrlParameter('appid'), {
            minZoom: 1,
            maxZoom: 15
        });
        rainLayer.setOpacity(0.7);


        // Temperature
        var tempLayer = new L.TileLayer("https://tile.openweathermap.org/map/temp_new/{z}/{x}/{y}.png?appid=" + getUrlParameter('appid'), {
            minZoom: 1,
            maxZoom: 15
        });
        tempLayer.setOpacity(0.7);

        map.on("moveend", function () {
            NativeInterface.transferLatLon(map.getCenter().lat, map.getCenter().lng);
        });

        map.on("zoomend", function () {
            NativeInterface.transferZoom(map.getZoom());
        });
    </script>

</body>

</html>
